import { Controller, Get, Post, Put, Delete, Body, Param } from '@nestjs/common';
import { AppService } from './app.service';

@Controller('api')
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('users')
  getUsers() {
    return { users: [
      { id: 1, name: 'Alice' },
      { id: 2, name: 'Bob' }
    ]};
  }

  @Get('users/:id')
  getUserById(@Param('id') id: string) {
    return { id: parseInt(id), name: 'Alice' };
  }

  @Post('users')
  createUser(@Body() user: any) {
    return { message: 'User created', user };
  }

  @Put('users/:id')
  updateUser(@Param('id') id: string, @Body() user: any) {
    return { message: 'User updated', id: parseInt(id), user };
  }

  @Delete('users/:id')
  deleteUser(@Param('id') id: string) {
    return { message: 'User deleted', id: parseInt(id) };
  }
}
